package com.atde._01_principle.liskov;


/**
 * @Author: Del
 * @CreateTime: 2025-04-12
 * @Description: 里氏替换原则
 * @Version: 1.0
 */
public class Liskov02 {
    public static void main(String[] args) {
        Sub02 sub02 = new Sub02();
        int result = sub02.func03(1, 2);
        System.out.println(result);
    }
}

class Base {

}

class Sub01 extends Base {
    public int func01(int a, int b) {
        return a - b;
    }
}

class Sub02 extends Base {
    // 如果我们B需要使用 Sub01 的方法，使用组合关系
    private Sub01 sub01 = new Sub01();

    public Sub02() {

    }

    public int func01(int a, int b) {
        return a + b;
    }

    public int func02(int a, int b) {
        return func01(a, b) + 9;
    }

    public int func03(int a, int b) {
        return sub01.func01(a, b) + 9;
    }
}
